package com.gaofei.controller;

import java.io.File;
import java.io.IOException;
import java.util.UUID;

import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.gaofei.domain.Brand;
import com.gaofei.domain.Category;
import com.gaofei.service.BrandService;
import com.gaofei.service.CatService;
import com.github.pagehelper.PageInfo;

@Controller
@RequestMapping("cat")
public class CatController {

	@Reference
	private CatService catService;
	
	@RequestMapping("update")
	@ResponseBody
	public boolean update(Category category) {
		try {
			catService.update(category);
			
			return true;
		} catch (Exception e) {
			return false;
		}
	}
	
	@RequestMapping("del")
	@ResponseBody
	public boolean del(Category category) {
		try {
			catService.delCat(category);
			
			return true;
		} catch (Exception e) {
			return false;
		}
	}
	
	@RequestMapping("add")
	@ResponseBody
	public boolean add(Category category) {
		try {
			catService.addCat(category);
			
			return true;
		} catch (Exception e) {
			return false;
		}
	}
	
	
	@RequestMapping("list")
	public String list() {
		return "category/list";
	}
	
	//添加方法
	@RequestMapping("getTree")
	@ResponseBody
	public Object initTree(Integer id) {
		return catService.getTree(id);
	}
}
